package com.handu.luna.core.domain.promotion;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.handu.luna.core.domain.BaseRepository;

public interface CreditGoodsGoodsRepository extends JpaRepository<CreditGoodsGoods,Long>,BaseRepository<CreditGoodsGoods>,JpaSpecificationExecutor<CreditGoodsGoods> {
	
	@Query("from CreditGoodsGoods s  where s.creditGoodsId = :creditGoodsId order by id desc")
	Page<CreditGoodsGoods> findByCreditGoodsId(@Param("creditGoodsId") long creditGoodsId,Pageable pageable);
	
	@Query("from CreditGoodsGoods s  where s.creditGoodsId = :creditGoodsId AND goodsId = :goodsId ")
	CreditGoodsGoods findByCreditGoodsIdAndGoodsId(@Param("creditGoodsId") long creditGoodsId,@Param("goodsId") long goodsId);
	
	@Query("from CreditGoodsGoods s  where s.creditGoodsId = :creditGoodsId AND goodsId = :goodsId ")
	List<CreditGoodsGoods> findByCreidGoodsIdAndGoodsId(@Param("creditGoodsId") long creditGoodsId,@Param("goodsId") long goodsId);

    @Query("from CreditGoodsGoods s  where s.creditGoodsId = :creditGoodsId")
    List<CreditGoodsGoods> findByCreditGoodsId(@Param("creditGoodsId") long creditGoodsId);
	/*@Modifying
	@Query("delete from creditPromotionGoods s  where s.creditPromotionId = :creditPromotionId")
	public void deleteByPromotionId(@Param("creditPromotionId") int creditPromotionId);*/
}
